package com.owen.springboot.smartparkingms.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * file映射项目外文件夹
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {

	@Value("${file.path}")
	private String filePath;    //从配置获取车辆图片上传路径

	/**
	 * 修改资源处理器
	 * @param registry
	 */
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/file/**").addResourceLocations("file:" + filePath+"/");
	}
}
